package org.example.service.impl;

import org.example.mapper.ReservationMapper;
import org.example.pojo.domain.Reservation;
import org.example.service.ReservationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ReservationServiceImpl implements ReservationService {

    @Autowired
    private ReservationMapper reservationMapper;

    @Override
    public int getVisitorsCount() {
        return reservationMapper.countConfirmedVisitorsByDate(new Date());
    }

    @Override
    public List<Reservation> listReservationsByUser(Integer userId) {
        return reservationMapper.findByUserId(userId);
    }

    @Override
    public void makeReservation(Reservation reservation) {
        reservationMapper.insertReservation(reservation);
    }

    @Override
    public void cancelReservation(Integer reservationId) {
        reservationMapper.updateReservationStatus(reservationId, "cancelled");
    }

    @Override
    public Reservation getReservationDetails(Integer reservationId) {
        return reservationMapper.findById(reservationId);
    }
}
